<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: xwj32
  Date: 2023-05-19
  Time: 0:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>药品介绍</title>
  <!-- 引入 Bootstrap 样式 -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css">
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.min.js"></script>
  <jsp:include page="include/mangerheadtag.jsp"/>
</head>
<body>
<jsp:include page="include/head.jsp"/>
<jsp:include page="include/menu.jsp"/>


<div class="container my-5" style="margin-top: 100px;margin-left: 300px">
  <div class="container mt-5">
    <div class="row"  style="margin-top: 30px">
      <div class="col-md-6">
        <div class="input-group">
          <form action="<%=request.getContextPath()%>/medicineServlet" method="get">
          <input type="text" class="form-control" name="name" placeholder="请输入药品名称" style="width: 300px">
          <input type="hidden" name="action" value="searchByName">
          <input type="submit" class="btn btn-primary" value="查找药品">
          </form>
        </div>
      </div>

      <div class="col-md-6">
        <div class="input-group">
          <form action="<%=request.getContextPath()%>/medicineServlet" method="get">
            <input type="hidden" name="action" value="searchByCategory">
          <input type="text" class="form-control" name="category" placeholder="请输入药品类别" style="width: 300px">
         <input type="submit" class="btn btn-primary" value="查找药品">
          </form>
        </div>
      </div>
    </div>
  </div>

  <c:if test="${requestScope.medicineList!=null}">
  <c:forEach items="${requestScope.medicineList}" var="medicine">
  <h2 style="margin-top: 50px" class="text-center">${medicine.name}</h2>
  <hr>
  <div class="row my-5">
    <div class="col-md-6">
      <h3>药品基本信息</h3>
      <table class="table table-striped">
        <tbody>
        <tr>
          <th>药品编码</th>
          <td>${medicine.code}</td>
        </tr>
        <tr>
          <th>药品分类</th>
          <td>${medicine.category}</td>
        </tr>
        <tr>
          <th>药品规格</th>
          <td>${medicine.specification}</td>
        </tr>
        <tr>
          <th>药品产地</th>
          <td>${medicine.producer}</td>
        </tr>
        </tbody>
      </table>
    </div>
    <div class="col-md-6">
      <h3>价格及库存信息</h3>
      <table class=" table table-striped">
        <tbody>
        <tr>
          <th>价格</th>
          <td>${medicine.price}元</td>
        </tr>
        <tr>
          <th>库存数量</th>
          <td>${medicine.quantity}</td>
        </tr>
        <tr>
          <th>药品功效</th>
          <td>${medicine.efficacy}</td>
        </tr>
        <tr>
          <th>操作</th>
          <td> <a href="<%=request.getContextPath()%>/medicineRecordServlet?action=addRecord&mid=${medicine.mid}" class="btn btn-primary" >预约购买</a></td>
        </tr>
        </tbody>
      </table>
    </div>
  </div>
</c:forEach>
  </c:if>


<%--  搜索药品分类--%>

  <c:if test="${requestScope.medicineListCategory!=null}">
    <c:forEach items="${requestScope.medicineListCategory} " var="medicine">
      <h2 style="margin-top: 50px" class="text-center">${medicine.name}</h2>
      <hr>
      <div class="row my-5">
        <div class="col-md-6">
          <h3>药品基本信息</h3>
          <table class="table table-striped">
            <tbody>
            <tr>
              <th>药品编码</th>
              <td>${medicine.code}</td>
            </tr>
            <tr>
              <th>药品分类</th>
              <td>${medicine.category}</td>
            </tr>
            <tr>
              <th>药品规格</th>
              <td>${medicine.specification}</td>
            </tr>
            <tr>
              <th>药品产地</th>
              <td>${medicine.producer}</td>
            </tr>
            </tbody>
          </table>
        </div>
        <div class="col-md-6">
          <h3>价格及库存信息</h3>
          <table class=" table table-striped">
            <tbody>
            <tr>
              <th>价格</th>
              <td>${medicine.price}元</td>
            </tr>
            <tr>
              <th>库存数量</th>
              <td>${medicine.quantity}</td>
            </tr>
            <tr>
              <th>药品功效</th>
              <td>${medicine.efficacy}</td>
            </tr>
            <tr>
              <th>操作</th>
              <td> <a href="#" class="btn btn-primary" >预约购买</a></td>
            </tr>
            </tbody>
          </table>
        </div>
      </div>
    </c:forEach>
  </c:if>


<%--  搜索药品名字--%>
  <c:if test="${requestScope.medicine!=null}">

    <h2 style="margin-top: 50px" class="text-center">${requestScope.medicine.name}</h2>
    <hr>
    <div class="row my-5">
      <div class="col-md-6">
        <h3>药品基本信息</h3>
        <table class="table table-striped">
          <tbody>
          <tr>
            <th>药品编码</th>
            <td>${requestScope.medicine.code}</td>
          </tr>
          <tr>
            <th>药品分类</th>
            <td>${requestScope.medicine.category}</td>
          </tr>
          <tr>
            <th>药品规格</th>
            <td>${requestScope.medicine.specification}</td>
          </tr>
          <tr>
            <th>药品产地</th>
            <td>${requestScope.medicine.producer}</td>
          </tr>
          </tbody>
        </table>
      </div>
      <div class="col-md-6">
        <h3>价格及库存信息</h3>
        <table class=" table table-striped">
          <tbody>
          <tr>
            <th>价格</th>
            <td>$requestScope.{medicine.price}元</td>
          </tr>
          <tr>
            <th>库存数量</th>
            <td>${requestScope.medicine.quantity}</td>
          </tr>
          <tr>
            <th>药品功效</th>
            <td>${requestScope.medicine.efficacy}</td>
          </tr>
          <tr>
            <th>操作</th>
            <td> <a href="#" class="btn btn-primary" >预约购买</a></td>
          </tr>
          </tbody>
        </table>
      </div>
    </div>
  </c:if>
</div>
<!-- 引入 Bootstrap JavaScript 库 -->

</body>
</html>
